local hx__longji = fk.CreateSkill{
    name = "hx__longji",

    tags = {Skill.Wake},
}

hx__longji:addEffect(fk.EnterDying,{
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(hx__longji.name) and target and target == player and player.hp < 1 and player:usedEffectTimes(self.name,Player.HistoryGame) == 0
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:changeMaxHp(player,13-player.maxHp)
        room:changeHp(player,13-player.hp)
        room:changeShield(player,13-player.shield)
        if player:getHandcardNum() > 13 then
            local num = player:getHandcardNum() - 13
            room:askToDiscard(player,{ min_num = num,max_num = num, skill_name = hx__longji.name, cancelable = false, include_equip = false, pattern = "." , prompt = "#hx__longji__tiaozheng",  })
        elseif player:getHandcardNum() < 13 then
            local num = 13 - player:getHandcardNum()
            player:drawCards(num,hx__longji.name)
        end
    end,
})

hx__longji:addEffect(fk.RoundEnd,{
    can_refresh = function (self, event, target, player, data)
        return player:hasSkill(hx__longji.name) and player:usedSkillTimes(hx__longji.name,Player.HistoryGame) > 0
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        local targets = player:getFriends(true,false)
        for _, v in ipairs(targets) do
            room:killPlayer({who = v, killer = player})
        end
    end,
})



return hx__longji